#!/usr/bin/php

<?php

$stderr = fopen('php://stderr', 'w');

array_shift($argv);

require dirname(__FILE__) . '/Packager/packager.php';

$package = dirname(__FILE__) . '/Source';

$pkg = new Packager($package);

$files = (empty($argv)) ? $pkg->get_all_files() : $pkg->components_to_files($argv);

$files = $pkg->complete_files($files);

fwrite($stderr, "/**\n");
fwrite($stderr, " * AtomJS\n * \n");
fwrite($stderr, " * Included Components:\n");
foreach ($files as $file){
	fwrite($stderr, " * - $file\n");
}
fwrite($stderr, " */\n\n");

$output = $pkg->build($files, array(), array(), array());

echo $output;

fclose($stderr);

?> 
